package com.gopay.cashier.web.command;

import org.apache.commons.lang.StringUtils;

import com.gopay.common.constants.trans.PayChannel;
import com.gopay.common.constants.trans.PayUserType;



/**
 * @author Administrator
 * 网银支付参数列表
 */
public class BankPayChannelCommand extends PayChannelCommand {

	private static final long serialVersionUID = -9122210644749313042L;

    /**
     * F:全额银行卡支付； S:差额支付；
     */
    private BankPayWay payWay;
    
    /**
     * 付款渠道类型
     * @PayChannel
     */
    private String payChannel;
    /**
     * 选择支付的银行代码
     */
    private String payBankCode;
    
    /**
     * 个人银行
     */
    private String personalPayBankCode;
    /**
     * 企业银行
     */
    private String corpPayBankCode;
    
    
    /**
     * 风控校验码
     */
    private String verifyCode;
    
    /**
     * 新产生的充值交易ID
     */
    private String inChargeOrderId;


    private String errId;
    private String errMsg;

    /**
     * 是否选择更多银行
     */
    private String payBankCodeAll;

    /**
     * 是否风控校验
     */
    private String antiPhish;
    /**
     * B2C返回2； B2B返回1；
     */
    
    private String dcErrMesg;
    
    
    public PayUserType getUserType() {
        if (StringUtils.equals(payChannel, PayChannel._51.value)) {
            return PayUserType.USER_TYPE_C;
        } else if (StringUtils.equals(payChannel, PayChannel._01.value)) {
            return PayUserType.USER_TYPE_P;
        }
        return null;
    }

    /**
     * 是否为银行卡全额支付
     * 
     * @return
     */
    public boolean isFullBankPay() {
        if (BankPayWay.F.equals(payWay)) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 是否为银行卡差额支付
     * 
     * @return
     */
    public boolean isShortfallPay() {
        if (BankPayWay.S.equals(payWay) || BankPayWay.A.equals(payWay)) {
            return true;
        } else {
            return false;
        }
    }
    
	public BankPayWay getPayWay() {
		return payWay;
	}

	public void setPayWay(BankPayWay payWay) {
		this.payWay = payWay;
	}


	public void setPayChannel(String payChannel) {
		this.payChannel = payChannel;
	}
	
	public String getPayChannel(){
	    return this.payChannel;
	    
        //edit by fanghw 20160523
//        if(StringUtils.isNotBlank(payBankCodeAll)){
//            int t = payBankCodeAll.indexOf("-");
//            if(t !=-1 ){
//                if(StringUtils.equals(payBankCodeAll.substring(0,t),"3"))
//                    return PayChannel._01.value;
//                if(StringUtils.equals(payBankCodeAll.substring(0,t),"4"))
//                    return PayChannel._51.value;
//            }
//        }
        
    }
    

    
    public String getPayBankCode() {
      //edit by fanghw 20160523     
        if(PayChannel._01.value.equals(this.getPayChannel())){
            return this.getPersonalPayBankCode();
        }if(PayChannel._51.value.equals(this.getPayChannel())){
            return this.getCorpPayBankCode();
        }
        
        return null;
        
        /*
        if(StringUtils.isBlank(payBankCodeAll)){
            if(StringUtils.isNotBlank(corpPayBankCode))
                return corpPayBankCode;

            if(StringUtils.isNotBlank(personalPayBankCode))
                return personalPayBankCode;
        }else{
            int t = payBankCodeAll.indexOf("-");
            if(t !=-1 && (StringUtils.equals(payBankCodeAll.substring(0,t),"3") || StringUtils.equals(payBankCodeAll.substring(0,t),"4"))){
                return payBankCodeAll.substring(t+1,payBankCodeAll.length());
            }
        }
        
        return payBankCode;
        */
    }


	public void setPayBankCode(String payBankCode) {
		this.payBankCode = payBankCode;
	}

	public String getPersonalPayBankCode() {
		return personalPayBankCode;
	}

	public void setPersonalPayBankCode(String personalPayBankCode) {
		this.personalPayBankCode = personalPayBankCode;
	}

	public String getCorpPayBankCode() {
		return corpPayBankCode;
	}

	public void setCorpPayBankCode(String corpPayBankCode) {
		this.corpPayBankCode = corpPayBankCode;
	}

	public String getVerifyCode() {
		return verifyCode;
	}

	public void setVerifyCode(String verifyCode) {
		this.verifyCode = verifyCode;
	}

	public String getInChargeOrderId() {
		return inChargeOrderId;
	}

	public void setInChargeOrderId(String inChargeOrderId) {
		this.inChargeOrderId = inChargeOrderId;
	}

    public String getErrId() {
        return errId;
    }

    public void setErrId(String errId) {
        this.errId = errId;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    public String getPayBankCodeAll() {
        return payBankCodeAll;
    }

    public void setPayBankCodeAll(String payBankCodeAll) {
        this.payBankCodeAll = payBankCodeAll;
    }

    public String getAntiPhish() {
        return antiPhish;
    }

    public void setAntiPhish(String antiPhish) {
        this.antiPhish = antiPhish;
    }

	public String getDcErrMesg() {
		return dcErrMesg;
	}

	public void setDcErrMesg(String dcErrMesg) {
		this.dcErrMesg = dcErrMesg;
	}
}
